/**
 * 
 */
package wangjg.commons.io;

import java.io.File;
import java.io.IOException;

/**
 * @author wangjg
 *
 */
public class DirUtil {

	public void recursion(File file){
		if(file.isFile()){
			this.handle(file);
		}else if(file.isDirectory()){
			File[] files = file.listFiles();
			for(File f:files){
				recursion(f);
			}
		}
	}

	protected void handle(File file) {
		try {
			String extname = FileHeaderHelper.getExtName(file.getPath());
			if(extname!=null){
				file.renameTo(new File(file.getPath()+"."+extname));
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
		
	}
	
	public static void main(String args[]){
		new DirUtil().recursion(new File("D:\\用户目录\\我的文档\\Tencent Files\\10047902\\FileRecv\\MobileFile\\EarlyLearning"));
		System.out.println("over.");
	}
}
